# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     day112_pyqt5_gridlayout
   Description :
   Author :       fuml
   date：          2019/9/20
-------------------------------------------------
   Change Activity:
                   2019/9/20:
-------------------------------------------------
"""

import  sys
from PyQt5.QtWidgets import (QWidget,QApplication,QLabel,QPushButton,
                             QVBoxLayout,QHBoxLayout,QGridLayout)
from PyQt5.QtGui import QIcon

class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        gridlayout = QGridLayout()
        self.setLayout(gridlayout)
        names=['Cls','Bck','','Close',
               '7','8','9','/',
               '4','5','6','*',
               '1','2','3','-',
               '0','.','=','+']
        positions =[(i,j) for i in range(5) for j in range(4)]

        for position,name in zip(positions,names):
            if name == '':
                continue
            button = QPushButton(name)
            gridlayout.addWidget(button,*position)

        #set gemotry
        self.setGeometry(300,300,300,150)
        self.setWindowTitle('Calculator')
        #self.setWindowIcon(QIcon('web.png'))


        self.show()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex=Example()
    sys.exit(app.exec_())
